package top.shen33.yang.services.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import top.shen33.yang.model.entity.SysFieldDetail;
import top.shen33.yang.mapper.SysFieldDetailMapper;
import top.shen33.yang.services.SysFieldDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 字段 服务实现类
 * </p>
 *
 * @author oreilly
 * @since 2018-09-17
 */
@Service
public class SysFieldDetailServiceImpl extends ServiceImpl<SysFieldDetailMapper, SysFieldDetail>implements SysFieldDetailService {

    @Override
    public Class clazz() {
        return SysFieldDetail.class;
    }

    @Override
    @Transactional
    public void doAdd(SysFieldDetail itemSysFieldDetail) {

        itemSysFieldDetail.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doUpdate(SysFieldDetail itemSysFieldDetail) {

        itemSysFieldDetail.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doDelete(String[] ids) {

        QueryWrapper<SysFieldDetail> ew = new QueryWrapper<>();
        ew.in("sid", ids);
        new SysFieldDetail().delete(ew);
    }

    @Override
    public SysFieldDetail getOne(String sid) {

        //关联查询

        SysFieldDetail itemSysFieldDetail = getById(sid);

        return itemSysFieldDetail;
    }

    @Override
    public List<SysFieldDetail> all(SysFieldDetail itemSysFieldDetail) {

        return this.baseMapper.all(itemSysFieldDetail);
    }


        @Override
    public Page<SysFieldDetail> pageInfo(Page page, SysFieldDetail itemSysFieldDetail) {

        List<SysFieldDetail> dataList = this.baseMapper.pageInfo(page, itemSysFieldDetail);
        if(page ==null ){
            page = new Page(0,10000);
        }
        page.setRecords(dataList);
        return page;
    }


    @Override
    @Transactional
    public void doImport(List<SysFieldDetail> dataList) {

        //数据验证

        //保存
        this.saveOrUpdateBatch(dataList);
    }

}
